package com.tianzj.boot.mvc.controller.system;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import com.tianzj.boot.mvc.service.system.SysRoleMenuService;

import lombok.extern.slf4j.Slf4j;

@RestController()
@RequestMapping("sysRoleMenu")
@Slf4j
public class SysRoleMenuController {
		
	@Autowired
	private SysRoleMenuService sysRoleMenuService;
	/**
	 * 权限分配
	 * @param roleId
	 * @param menuIds
	 * @return
	 */
	@PostMapping("addSysAssignRoleMenu")
	public ModelAndView addSysAssignRoleMenu(Long roleId,String menuIds){
		try {
			//sysRoleMenuService.deleteByRoleId(roleId);
			sysRoleMenuService.saveRoleMenu(roleId,menuIds);
		} catch (Exception e) {
			log.error("权限分配失败"+e.getMessage());
		}
		return new ModelAndView("redirect:/sysRole/roleList");
	}
}
